package com.zq.designpaterns.structure.flyweight;

import java.util.HashMap;
import java.util.Map;

/**
 * ================================================
 * 作    者：程志强
 * 邮    箱：cheng.zhiqiang@cesgroup.com.cn
 * 版    本：1.0.0
 * 创建日期：2021/01/12  14:54
 * 修改日期：
 * 描    述：
 * 修订历史：
 * ================================================
 */
public class ShapeFactory {
    private static final Map<String, Shape> circleMap = new HashMap<>();

    public static Shape getCircleShape(String color) {
        Circle shapeCircle = (Circle) circleMap.get(color);
        if (null == shapeCircle) {
            shapeCircle = new Circle(color);
            circleMap.put(color, shapeCircle);
            System.out.println("Creating circle of color : " + color);
        }
        return shapeCircle;
    }
}
